package com.zlp.controller;

import com.ulisesbocchio.jasyptspringboot.encryptor.DefaultLazyEncryptor;
import org.jasypt.encryption.StringEncryptor;
import org.springframework.core.env.StandardEnvironment;

/** 
 * TODO
 * @param null
 * @date: 2021/4/2 9:25
 * @return:  
 */
public class TestController {

    public static void main(String[] args) {
        //对应配置文件中对应的根密码
        System.setProperty("jasypt.encryptor.password", "pig");
        StringEncryptor stringEncryptor = new DefaultLazyEncryptor(new StandardEnvironment());
//        //加密方法
        System.out.println(stringEncryptor.encrypt("pig"));
        //解密方法
        System.out.println(stringEncryptor.decrypt(stringEncryptor.encrypt("pig")));
        //imENTO7M8bLO38LFSIxnzw==
        System.out.println("==="+stringEncryptor.decrypt("imENTO7M8bLO38LFSIxnzw=="));

    }
}
